package com.fc.mall.kdniao.autoconfigure;

import com.fc.mall.kdniao.properties.KDNiaoProperties;
import com.fc.mall.kdniao.service.KDNiaoService;
import com.fc.mall.kdniao.service.impl.KDNiaoServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(KDNiaoProperties.class)
@ConditionalOnClass(KDNiaoService.class)
@ConditionalOnProperty(prefix = "kdniao", value = "enabled", havingValue = "true", matchIfMissing = true)
public class KDNiaoAutoConfigure {

    @Bean
    @ConditionalOnMissingBean(KDNiaoService.class)
    public KDNiaoService kdNiaoService() {
        KDNiaoService kdNiaoService = new KDNiaoServiceImpl();
        return kdNiaoService;
    }
}